package ltd.ninefish.framework.systemapi.service;

import ltd.ninefish.framework.core.constant.SecurityConst;
import ltd.ninefish.framework.core.constant.ServiceNameConst;
import ltd.ninefish.framework.core.result.Result;
import ltd.ninefish.framework.systemapi.dto.LoginUserDto;
import ltd.ninefish.framework.systemapi.dto.SysUserDto;
import ltd.ninefish.framework.systemapi.factory.RemoteUserFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

/**
 * @author zhaoxiubin
 * create-time 2024-01-16 8:42
 * description 用户服务
 **/
@FeignClient(contextId = "remoteUserService", value = ServiceNameConst.SYSTEM_SERVICE, fallbackFactory = RemoteUserFallbackFactory.class)
public interface RemoteUserService {
    /**
     * 通过用户名查询用户信息
     *
     * @param username 用户名
     * @param source 请求来源
     * @return 结果
     */
    @GetMapping("/user/info/{username}")
    public Result<LoginUserDto> getUserInfo(@PathVariable("username") String username, @RequestHeader(SecurityConst.FROM_SOURCE) String source);

    /**
     * 通过微信标识查询用户信息
     *
     * @param openid 微信标识
     * @param source 请求来源
     * @return 结果
     */
    @GetMapping("/user/info-wx/{openid}")
    public Result<LoginUserDto> getUserInfoByWx(@PathVariable("openid") String openid, @RequestHeader(SecurityConst.FROM_SOURCE) String source);

    /**
     * 通过手机号查询用户信息
     *
     * @param mobile 手机号
     * @param source 请求来源
     * @return 结果
     */
    @GetMapping("/user/info-tel/{mobile}")
    public Result<LoginUserDto> getUserInfoByTel(@PathVariable("mobile") String mobile, @RequestHeader(SecurityConst.FROM_SOURCE) String source);

    /**
     * 注册用户信息
     *
     * @param sysUser 用户信息
     * @param source 请求来源
     * @return 结果
     */
    @PostMapping("/user/register")
    public Result<Boolean> registerUserInfo(@RequestBody SysUserDto sysUser, @RequestHeader(SecurityConst.FROM_SOURCE) String source);
}
